package com.example.JavaWebApi.controller.neo4j;

import com.example.JavaWebApi.core.mqtt.MqttConfig;
import com.example.JavaWebApi.model.neo4j.node.Movie;
import com.example.JavaWebApi.model.neo4j.result.RelationVo;
import com.example.JavaWebApi.service.neo4j.IMovieService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: java-web-api
 * @description:
 * @author: 杨泽
 * @create: 2023-09-13 13:48
 */
@RestController
@RequestMapping("/api/movie")
@Api(tags = "电影")
public class MovieController {
    @Autowired
    private IMovieService movieService;
//    @Autowired
//    private MqttConfig providerClient;
    @PostMapping("Save")
    @ApiOperation("保存")
    public Boolean save(@RequestBody Movie movie){
        return movieService.add(movie);
    }
    @GetMapping("GetAll")
    @ApiOperation("获取全部")
    public List<Movie> getAll(){
        return movieService.getAll();
    }
    @PostMapping("CreateRelation")
    @ApiOperation("创建关系")
    public Boolean createRelation(@RequestBody RelationVo relationVo){
        return movieService.createRelation(relationVo);
    }
    @PostMapping("CreateRelation1")
    @ApiOperation("创建关系1")
    public Boolean createRelation1(@RequestBody RelationVo relationVo){
        return movieService.createRelation1(relationVo);
    }

    @SneakyThrows
    @GetMapping("/sendMessage")
    @ApiOperation("测试发送数据")
    public String sendMessage(int qos,boolean retained,String topic,String message){
        //providerClient.publish(qos, retained, topic, message);
        return "发送成功";
    }
}